package com.prs.crm.action.approval;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.approval.ProcessNode;
import com.prs.crm.domain.approval.TableCss;
import com.prs.crm.service.approval.TableCssService;

public class TableCssAction extends BaseAction{
	private PaginationSupport pagination;
	private Integer[] ids;
	private TableCss tableCss;
	private TableCssService tableCssService;
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	public TableCss getTableCss() {
		return tableCss;
	}
	public void setTableCss(TableCss tableCss) {
		this.tableCss = tableCss;
	}
	public TableCssService getTableCssService() {
		return tableCssService;
	}
	public void setTableCssService(TableCssService tableCssService) {
		this.tableCssService = tableCssService;
	}
	/////////////////////////////////////////////////////////////////
	@Action("listTableCss")
	public String listTableCss(){
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(TableCss.class);
		this.setPagination(this.tableCssService.listByPage(criteria, 
				this.getPaginationHelper().prepare(pagination)));
		return SUCCESS;
	}
	@Action("editTableCss")
	public String editTableCss(){
		return SUCCESS;
	}
	@Action(value="saveTableCss",results={
			@Result(name="success",type="redirect",location="listTableCss"),
			@Result(name="error",type="chain",location="editTableCss")
	})
	public String saveTableCss(){
		if(tableCss.getName() == null || "".equals(tableCss.getName())){
			this.addActionError("带*号为必填！");
			return ERROR;
		}
		this.tableCssService.save(tableCss);
		return SUCCESS;
	}
	@Action(value="removeTableCss",results={
			@Result(name="success",type="redirect",location="listTableCss"),
			@Result(name="error",type="chain",location="listTableCss")
	})
	public String removeTableCss(){
		if(ids==null){
			this.setPrompt("请选择一行数据！");
			return ERROR;
		}
		this.tableCssService.batchRemove(ids);
		return SUCCESS;
	}
	
}
